<%@ page import="java.io.*, java.text.*, java.util.Date, java.sql.*, javax.servlet.*, javax.servlet.http.*, java.util.*,database.*" %>
<%@ include file="IsAdmin.jsp"%><%
try{
DBCon db1 = new DBCon();
int sizeOfP = db1.countUsers(",professor where type='professor' and professor.username = userlogin.username");
ResultSet res2 = db1.getUsers(",professor where type='professor' and professor.username = userlogin.username");
String [] usernamesP = new String[sizeOfP];

for(int i=0;res2.next();i++)
    usernamesP[i] = res2.getString("firstname")+" "+res2.getString("lastname");

int sizeOfC = db1.countUsers(",professor  where type='committee' and professor.username = userlogin.username");
ResultSet res3 = db1.getUsers(",professor  where type='committee' and professor.username = userlogin.username");
String [] usernamesC = new String[sizeOfC];

for(int i=0;res3.next();i++)
    usernamesC[i] = res3.getString("firstname")+" "+res3.getString("lastname");

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head> 
		<%@ include file="../master/head.jsp" %>
                 
		<script type="text/javascript" src="js/drag_drop_type.js"></script>
		<link rel="STYLESHEET" href="styles/project.css" type="text/css">
		<link rel="stylesheet" href="styles/control.css" type="text/css"/>
		<script type="text/javascript">
                     var isThereIsChange = false;
function check() {
var it = new Array();
<%
        int i=0;
	for(;i<usernamesP.length;i++)
	{
		out.println("it["+i+"] = document.getElementById('"+usernamesP[i]+"');");
	}
        
                for(;i<usernamesC.length+usernamesP.length;i++)
	{
		out.println("it["+i+"] = document.getElementById('"+usernamesC[i-usernamesP.length]+"');");
	}
%>
for(var i=0;i<it.length;i++)
{
	if(it[i] != null && it[i].parentNode.id == "DragContainer4")
	{
		document.getElementById("in"+i).value = "professor";
	}
	else if(it[i] != null && it[i].parentNode.id == "DragContainer5")
	{
		document.getElementById("in"+i).value = "committee";
	}
	isThereIsChange = true;
        
}
var links = document.body.getElementsByTagName("a");
for(var i=0;i<links.length;i++)
{
    links[i].onclick = function() {
        return confirm("You made changes on professors type\nDo you want to discard it? if you do not click save changes button");
    }
}
return true;
}
		</script>
	</head>
	<body>
		<div id="container">
			<div id="wrapper">
				<div id="sidebar">
					<div id="sb_top">
						<%@ include file="../master/sbTop.jsp" %>
					</div>
					
					<div class="sb_content">
						
						<!--##########-->
							<!-- Start Menu -->
							<%@ include file="../master/adminMenu.jsp" %>
							
							<!-- Profile -->
							<%@ include file="../master/profile.jsp" %>
							
							<!-- links -->
							<%@ include file="../master/links.jsp" %>
						<div class="copyright">
							<%@ include file="../master/copyright.jsp" %>
						</div>
						
					</div> <!-- /sb_content -->
				</div> <!-- /sidebar -->
					
					
				<!-- Top -->
				<div id="header">
					<%@ include file="../master/header.jsp" %>
				</div>
				
				
				<!-- Start main content -->
				<div id="content">
					<div id="intro">
						<div class="intro_t">
							<h1><span>..</span>Welcome to<span>..</span></h1>
							<h2 >student project managment system</h2>
							
						</div>
					</div> <!-- /intro -->
                                         <TABLE BORDER="0" width="100%">
                                            <tr>
                                                <td><center><h2>Professors</h2></center></td>
                                                <td><center><h2>Committees</h2></center></td>
                                            </tr>
                                         </TABLE>
					<DIV id=Demo4 width="100%">
						<DIV class=DragContainer id=DragContainer4 overClass="OverDragContainer">
							<%
				 for (int x = 0; x < usernamesP.length; x++) {
							%>
							<DIV class=DragBox id="<%=usernamesP[x]%>" overClass="OverDragBox" dragClass="DragDragBox" ondblclick="openWindow(<%=usernamesP[x]%>)"><%=usernamesP[x]%></DIV>
							<%
				 }
							%>
						</DIV>
						<DIV class=DragContainer id=DragContainer5 overClass="OverDragContainer">
							<%
				 for (int x = 0; x < usernamesC.length; x++) {
							%>
							<DIV class=DragBox id="<%=usernamesC[x]%>" overClass="OverDragBox" dragClass="DragDragBox" ondblclick="openWindow(<%=usernamesC[x]%>)"><%=usernamesC[x]%></DIV>
							<%
				 }
							%>
						</DIV>
                                                 <form name="types" action="changeType.jsp" method="get">
						<%
                        int x=0;
			for(;x<usernamesP.length;x++)
			{
				%>
				<input type="hidden" id="in<%=x%>" name="<%=usernamesP[x]%>" value="professor" />
				<%
			}
                        for(;x<usernamesC.length+usernamesP.length;x++)
			{
				%>
				<input type="hidden" id="in<%=x%>" name="<%=usernamesC[x-usernamesP.length]%>" value="committee" />
				<%
			}
			}
catch(Exception e)
{
    response.sendRedirect("../connectionFailed.jsp?"+e);
}

			%>
                         <center><input type="submit" value="save changes"></center>
                                                </form>
					</DIV>
                                         	
				</div> <!-- /content -->
				
			</div> <!-- /wrapper -->
			<div class="clear">&nbsp;</div> <!-- Important! Fix the problem of height in Firefox -->
		</div> <!-- /Container -->
			
		
	</body>
</html>